/**
 * 地区特定配置文件
 * 演示纯 JavaScript 文件中的条件编译功能
 */

// 基础配置（所有地区共享）
export const baseConfig = {
  appName: "Fingers PC UI",
  version: "1.0.0",
  supportedLanguages: ["zh-CN", "ja-JP", "en-US"],
};

// 中国地区特定配置
// #ifdef cn
export const regionConfig = {
  region: "cn",
  currency: "CNY",
  language: "zh-CN",
  timezone: "Asia/Shanghai",
  apiBaseUrl: "https://api.example.cn",
  features: {
    payment: ["alipay", "wechat", "unionpay"],
    social: ["wechat", "weibo", "qq"],
    analytics: ["baidu", "umeng"],
  },
  theme: {
    primaryColor: "#ff4d4f",
    brandColor: "#f5222d",
  },
};

export const localizedMessages = {
  welcome: "欢迎使用 Fingers PC UI",
  loading: "加载中...",
  error: "发生错误",
  success: "操作成功",
};

// 中国特有的业务逻辑
export function initRegionSpecificFeatures() {
  console.log("初始化中国地区特有功能");
  setupAlipaySDK();
  setupWeChatSDK();
  setupBaiduAnalytics();
}

function setupAlipaySDK() {
  console.log("配置支付宝 SDK");
}

function setupWeChatSDK() {
  console.log("配置微信 SDK");
}

function setupBaiduAnalytics() {
  console.log("配置百度统计");
}
// #endif

// 日本地区特定配置
// #ifdef jp
export const regionConfig = {
  region: "jp",
  currency: "JPY",
  language: "ja-JP",
  timezone: "Asia/Tokyo",
  apiBaseUrl: "https://api.example.jp",
  features: {
    payment: ["rakuten", "paypay", "linepay"],
    social: ["line", "twitter", "instagram"],
    analytics: ["googleanalytics"],
  },
  theme: {
    primaryColor: "#eb2f96",
    brandColor: "#c41d7f",
  },
};

export const localizedMessages = {
  welcome: "Fingers PC UI へようこそ",
  loading: "読み込み中...",
  error: "エラーが発生しました",
  success: "操作が成功しました",
};

// 日本特有的业务逻辑
export function initRegionSpecificFeatures() {
  console.log("日本地域固有機能を初期化");
  setupRakutenSDK();
  setupLineSDK();
  setupGoogleAnalytics();
}

function setupRakutenSDK() {
  console.log("楽天 SDK を設定");
}

function setupLineSDK() {
  console.log("LINE SDK を設定");
}

function setupGoogleAnalytics() {
  console.log("Google Analytics を設定");
}
// #endif

// 美国地区特定配置
// #ifdef us
export const regionConfig = {
  region: "us",
  currency: "USD",
  language: "en-US",
  timezone: "America/New_York",
  apiBaseUrl: "https://api.example.com",
  features: {
    payment: ["stripe", "paypal", "applepay"],
    social: ["facebook", "twitter", "instagram"],
    analytics: ["googleanalytics", "mixpanel"],
  },
  theme: {
    primaryColor: "#52c41a",
    brandColor: "#389e0d",
  },
};

export const localizedMessages = {
  welcome: "Welcome to Fingers PC UI",
  loading: "Loading...",
  error: "An error occurred",
  success: "Operation successful",
};

// 美国特有的业务逻辑
export function initRegionSpecificFeatures() {
  console.log("Initializing US region specific features");
  setupStripeSDK();
  setupFacebookSDK();
  setupGoogleAnalytics();
}

function setupStripeSDK() {
  console.log("Setting up Stripe SDK");
}

function setupFacebookSDK() {
  console.log("Setting up Facebook SDK");
}

function setupGoogleAnalytics() {
  console.log("Setting up Google Analytics");
}
// #endif

// 合并配置的通用函数
export function getMergedConfig() {
  return {
    ...baseConfig,
    ...regionConfig,
  };
}

// 初始化函数（所有地区共用）
export function initApp() {
  console.log(`初始化应用 - 地区: ${regionConfig.region}`);
  console.log("配置信息:", getMergedConfig());

  // 初始化地区特定功能
  initRegionSpecificFeatures();

  // 通用初始化逻辑
  console.log("应用初始化完成");
}
